create database QL_NHA_HANG
go
use QL_NHA_HANG
go
create table TAMTINH(
	STT int NOT NULL Identity(1,1) primary key,
	Ten_Mon int NOT NULL,
	Don_Gia bigint,
	So_Luong int,
	Thanh_Tien bigint,
	Ban_An int

)
go
create table GIOVAO
(
	STT int identity(1,1) not null,
	Gio_Vao datetime,
	Id_Ban_An int not null,
	primary key(STT)

)
go
create table KHUVUC(
	Id_Khu_Vuc int NOT NULL Identity primary key,
	Ten_Khu_Vuc varchar(255) NOT NULL
)
go
create table PHUONGTHUCMUA(
	Id_Phuong_Thuc_Mua int NOT NULL Identity primary key,
	Ten_Phuong_Thuc varchar(255) NOT NULL
)
go
create table LOAIMONAN(
	Id_Loai_Mon_An int NOT NULL Identity primary key,
	Ten_Loai_Mon_An varchar(255) NOT NULL
)
go
create table LOAIMENU(
	Id_Loai_Menu int NOT NULL Identity primary key,
	Ten_Loai_Menu varchar(255) NOT NULL
)
go
create table LOAITAIKHOAN(
	Id_Loai_Tai_Khoan int NOT NULL Identity primary key,
	Ten_Loai_Tai_Khoan varchar(255) NOT NULL
)
go
create table DATBAN(
	Id_Dat_Ban int NOT NULL Identity primary key,
	Ten_Nguoi_Dat varchar(255) NOT NULL,
	So_dien_Thoai varchar(255) NOT NULL,
	Thoi_Gian_dat Datetime,
	Id_Khu_Vuc int,
	So_Luong_Ban int NOT NULL,
	Tinh_trang_Dat_Ban int NOT NULL
)
go
create table BANAN(
	Id_Ban_An int NOT NULL Identity primary key,
	Id_Khu_Vuc int,
	Ten_Ban_An varchar(255),
	Tinh_Trang_Ban_An int
)
go
create table TINHTIEN(
	Id_Tinh_tien int NOT NULL Identity primary key,
	Id_Phuong_Thuc_Mua int,
	Id_Hoa_Don int,
	Khuyen_Mai varchar(255),
	Tong_So_Tien int,
	Thanh_Tien int 
)
go
create table HOADON(
	Id_Hoa_don int NOT NULL Identity primary key,
	Id_Ban_An int,
	Gio_Vao datetime,
	Gio_Ra datetime,
	Ngay_Lap datetime,
	Id_Tai_Khoan int
)
go
create table MONAN(
	Id_Mon_An int NOT NULL identity primary key,
	Ten_Mon_An varchar(255),
	Id_Loai_Mon_An int,
	Id_Loai_Menu int,
	Don_gia int
)
go
create table CHITIETHOADON(
	Id_Hoa_Don int,
	Id_Mon_An int,
	So_Luong int,
	Don_Gia int,
	Thanh_Tien bigint,
)
go
create table TAIKHOAN(
	Id_Tai_Khoan int not null Identity primary key,
	User_Names char(255),
	Pass char(255),
	Id_Loai_Tai_Khoan  int
)
go
